﻿using InventoryIssue.API.Read.Application.Command.Stocktaking;
using InventoryIssue.Domain;
using InventoryIssue.Dtos;
using InventoryIssue.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace InventoryIssue.API.Read.Controllers
{
    /// <summary>
    /// 盘点控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class StocktakingController : ControllerBase
    {
        private readonly IMediator mediator;

        public StocktakingController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 分页查询盘点数据接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        
        public Task<APIPaging<StocktakingModel>> GetStocktaking([FromQuery]GetStocktakingCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 查询盘点产品接口
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<StocktakingProductDto>>> GetStocktakingProduct([FromQuery]GetStocktakingProductCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
